package com.very

import javax.servlet.annotation.WebServlet

import com.vaadin.annotations.{Theme, VaadinServletConfiguration}
import com.vaadin.server.{VaadinRequest, VaadinServlet}
import com.vaadin.ui._
/**
  * Created by Administrator on 2016/12/4 0004.
  */
class Demo {

}


@WebServlet(urlPatterns = Array("/*"), name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = classOf[MyUI], productionMode = false) class MyUIServlet extends VaadinServlet {}

@Theme ("stock")
class MyUI extends UI {
  protected def init(vaadinRequest: VaadinRequest) {
    val layout: VerticalLayout = new VerticalLayout
    val name: TextField = new TextField
    name.setCaption("Type your name here:")
    val button: Button = new Button("Click Me")

    button.addClickListener({e =>
      layout.addComponent(new Label("Thanks " + name.getValue()
        + ", it works!"))
    })
    layout.addComponents(name, button)
    layout.setMargin(true)
    layout.setSpacing(true)
    setContent(layout)
  }



}
